package com.hd.trans.files.bean;

import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;

public class Audio extends MediaEntity implements Parcelable {

    private int id; //歌曲ID
    private String tilte; //歌曲的名称
    private String album;  //歌曲的专辑名
    private String artist;  //歌曲的歌手名
    private String url;  //歌曲文件的全路径
    private Uri uri;//文件uri
    private String display_name;  //歌曲文件的名称
    private String year;  //歌曲文件的发行日期
    private String duration;  //歌曲的总播放时长
    private long size;  //歌曲文件的大小
    private String[] modifyTime;
    private long durations;  //歌曲时长  毫秒

    private boolean isDir; // 是否是目录
    private long times; // 存储时间


    private int imageRes; //图片

    private boolean isSelectFile = false;

    public Audio(int id, String name, String path, long date, long duration, long size) {
        super(id, name, path, date, duration, size);
    }

    public boolean getIsSelectFile() {
        return isSelectFile;
    }

    public Audio setIsSelectFile(boolean selectFile) {
        isSelectFile = selectFile;
        return this;
    }

    public Audio setImageRes(int imageRes) {
        this.imageRes = imageRes;
        return this;
    }

    public int getImageRes() {
        return imageRes;
    }

    public static Creator<Audio> getCREATOR() {
        return CREATOR;
    }

    public Audio setTimes(long times) {
        this.times = times;
        return this;
    }

    public long getTimes() {
        return times;
    }

    public boolean isDir() {
        return isDir;
    }

    public Audio setDir(boolean dir) {
        isDir = dir;
        return this;
    }

    public Audio setDurations(long durations) {
        this.durations = durations;
        return this;
    }

    public long getDurations() {
        return durations;
    }

    public Audio() {

    }

    protected Audio(Parcel in) {
        id = in.readInt();
        tilte = in.readString();
        album = in.readString();
        artist = in.readString();
        url = in.readString();
        display_name = in.readString();
        year = in.readString();
        duration = in.readString();
        size = in.readLong();
        durations = in.readLong();
    }

    public String[] getModifyTime() {
        return modifyTime;
    }

    public Audio setModifyTime(String[] modifyTime) {
        this.modifyTime = modifyTime;
        return this;
    }

    public static final Creator<Audio> CREATOR = new Creator<Audio>() {
        @Override
        public Audio createFromParcel(Parcel in) {
            return new Audio(in);
        }

        @Override
        public Audio[] newArray(int size) {
            return new Audio[size];
        }
    };

    public Audio setId(int id) {
        this.id = id;
        return this;
    }

    public Audio setTilte(String tilte) {
        this.tilte = tilte;
        return this;
    }

    public Audio setAlbum(String album) {
        this.album = album;
        return this;
    }

    public Audio setArtist(String artist) {
        this.artist = artist;
        return this;
    }

    public Audio setUrl(String url) {
        this.url = url;
        return this;
    }

    public Audio setUri(Uri uri) {
        this.uri = uri;
        return this;
    }

    public Audio setDisplay_name(String display_name) {
        this.display_name = display_name;
        return this;
    }

    public Audio setYear(String year) {
        this.year = year;
        return this;
    }

    public Audio setDuration(String duration) {
        this.duration = duration;
        return this;
    }

    public Audio setSize(long size) {
        this.size = size;
        return this;
    }

    public int getId() {
        return id;
    }

    public String getTilte() {
        return tilte;
    }

    public String getAlbum() {
        return album;
    }

    public String getArtist() {
        return artist;
    }

    public String getUrl() {
        return url;
    }

    public Uri getUri() {
        return uri;
    }

    public String getDisplay_name() {
        return display_name;
    }

    public String getYear() {
        return year;
    }

    public long getSize() {
        return size;
    }

    public Audio(int id, String tilte, String album, String artist, String url, String display_name, String year, String duration, long size, String[] modifyTime, long durations, boolean isDir, long times) {
        super(id, display_name, url, times, durations, size);
        this.id = id;
        this.tilte = tilte;
        this.album = album;
        this.artist = artist;
        this.url = url;
        this.display_name = display_name;
        this.year = year;
        this.duration = duration;
        this.size = size;
        this.modifyTime = modifyTime;
        this.durations = durations;
        this.isDir = isDir;
        this.times = times;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(tilte);
        dest.writeString(album);
        dest.writeString(artist);
        dest.writeString(url);
        dest.writeString(display_name);
        dest.writeString(year);
        dest.writeString(duration);
        dest.writeLong(size);
        dest.writeLong(durations);
    }

    @Override
    public String toString() {
        return "Audio{" +
                "id=" + id +
                ", tilte='" + tilte + '\'' +
                ", album='" + album + '\'' +
                ", artist='" + artist + '\'' +
                ", url='" + url + '\'' +
                ", display_name='" + display_name + '\'' +
                ", year='" + year + '\'' +
                ", duration='" + duration + '\'' +
                ", size=" + size +
//                ", modifyTime=" + Arrays.toString(modifyTime) +
                ", durations=" + durations +
                ", isDir=" + isDir +
                ", times=" + times +
                ", imageRes=" + imageRes +
                ", isSelectFile=" + isSelectFile +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Audio audio = (Audio) o;
        return id == audio.id && url.equals(audio.url);
    }
}